using System;
using Microsoft.SPOT;
using System.Reflection;

namespace Bt.DoorWebServer.Tests
{
    public class Class1
    {
        public static void Main()
        { 
             var assembly = typeof(Class1).Assembly;
             pok(assembly);
        }
        public void TestIsTrueAssertTrue()
        {
            try
            {
                Assert.IsTrue(true
                    , "This should not throw an exception");
            }
            catch (AssertException)
            {
                throw new AssertException(
                "Assert.IsTrue should not throw an exception for true");
            }
        }
        //public void TestStartsWith()
        //{
        //    string _testString = "freakyKey";
        //    Assert.IsTrue(!_testString.StartsWith("gav")
        //        , "The string freakyKey does not start with 'gav'");
        //    Assert.IsTrue(_testString.StartsWith("freak")
        //        , "The string freakyKey does start with 'freak'");
        //}

        //public void TestResult()
        //{
        //    var pok = new FillableViewResult();
        //    pok.Body = "Ahoj {LogFile} jak se mas ?";
        //    Debug.Print(pok.Body);
        //    Debug.Assert(1 == 1);
        //}

        public static void pok(Assembly assembly)        
        {
           
            Type[] types = assembly.GetTypes();
            foreach (var type in types)
            {
                MethodInfo[] methods =
                    type.GetMethods(BindingFlags.Public
                                    |BindingFlags.Instance);
                foreach (var method in methods)
                {
                    if (method.Name.Length >= 4 &&
                        method.Name.Substring(0, 4) == "Test")
                    {
                      
                        //try
                        //{
                        //    method.Invoke(null, null);
                        //}
                        //catch (Exception ex)
                        //{
                        //    result.Status = ResultType.Fail;
                        //    result.Exception = ex;
                        //}
                        //OnDisplayTestResult(new TestResultEventArgs
                        //        { TestResult = result });
                    }
                }
            }
        }
    }
}
